package com.huanbao.base.lang;

import lombok.Data;

import java.io.Serializable;

/**
 * @description:
 * @author: ZQ
 * @date: 2021-03-29-14:47
 */

@Data
public class Result implements Serializable {

    //200为成功
    private int code;
    private String message;
    private Object data;

    public static Result success(int code, String message, Object data){
        Result res = new Result();
        res.code = code;
        res.message = message;
        res.data = data;
        return res;
    }

    public static Result success(Object data){
        return success(200,"操作成功",data);
    }

    public static Result fail(int code, String message, Object data){
        Result res = new Result();
        res.code = code;
        res.message = message;
        res.data = data;
        return res;
    }

    public static Result fail(String message, Object data){
        return success(400, message, data);
    }

    public static Result fail(String message){
        return success(400, message, null);
    }

}
